<template>
  <div style="padding:20px">
    <h3>新增文创类别</h3>
    <el-form :inline="true" :model="form" :rules="rules" ref="ruleForm" style="width:80%" label-width="100px">
      <el-form-item label="文创类别名" prop="name">
        <el-input v-model="form.name" placeholder="请输入文创类别名"></el-input>
      </el-form-item>

      <el-form-item label="备注" prop="remark">
        <el-input v-model="form.remark" type="textarea" style="width:400px" placeholder="请输入备注信息内容"></el-input>
      </el-form-item>
    </el-form>

    <div style="text-align:center;margin-top:30px">
      <el-button type="primary" @click="save" size="medium">提交</el-button>
      <!--            <el-button type="danger">返回列表</el-button>-->
    </div>
  </div>
</template>

<script>
import request from "@/utils/request";
export default {
  name: "AddProductType",
  data(){
    return{
      form:{},
      rules: {
        name: [
          {required: true, message: '请输入类别名称', trigger: 'blur'},
        ]
      }
    }
  },
  methods: {
    save(){
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          //  save方法用于提交数据
          request.post('/producttype/save',this.form).then(res => {
            if (res.code === '200'){
              this.$notify.success('新增成功')
              //  新增成功后resetFields清空输入框内数据
              this.$refs['ruleForm'].resetFields();
            } else{
              this.$notify.error(res.msg)
            }
          })
        }
      })
    }
  }
}
</script>

<style scoped>

</style>